<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <style>
        /* 模态框背景 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
        }

        /* 模态框内容 */
        .modal-content {
            background-color: #f1f1f1;
            width: 300px;
            padding: 20px;
            border-radius: 5px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        /* 进度条容器 */
        .progress-container {
            width: 100%;
            height: 30px;
            background-color: #f1f1f1;
            margin-top: 10px;
            border: 1px solid #ccc;
            /* 添加外框 */
        }

        /* 进度条本身 */
        .progress-bar {
            width: 0;
            height: 100%;
            background-color: #4caf50;
        }

        /* 显示进度数字 */
        .progress-text {
            text-align: center;
            margin-top: 5px;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            设备应答
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:70px;">
        <div style="width:100%;margin-top:5%;"></div>
        <div class="aui-btn " style="margin-left:5%;width:40%;background-color: #FF4500;color: #ffffff;"
            onclick="getEquipFaultList('0')">已提交</div>
        <div class="aui-btn " style="margin-left:5%;width:40%;background-color: #7FFF00;color: #ffffff;"
            onclick="getEquipFaultList('2')">正在维修</div>
        <div style="width:100%;margin-top:2%;"></div>
        <div class="aui-btn aui-btn-info" style="margin-left:5%;width:40%;" onclick="goPageDetail()">考勤</div>
        <div class="aui-btn " style="margin-left:5%;width:40%;background-color: #FFD700;color: #ffffff;"
            onclick="getEquipFaultList('wtyl')">问题遗留</div>

        <div style="width:100%;margin-top:2%;"></div>
        <div
            style="background-color:white; width: 100%;margin-top:2%;overflow-x: auto;-webkit-overflow-scrolling:touch;">
            <table class="table" style='width:1460px;' id="table1">
                <thead>
                    <tr
                        style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-size: 15px;font-weight: bold;">
                        <td algin='center' style="width:50px;">序号</td>
                        <td algin='center' style="width:140px;">提报人</td>
                        <td algin='center' style="width:140px;">联系方式</td>
                        <td algin='center' style="width:140px;">发起时间</td>
                        <td algin='center' style="width:120px;;">维修类型</td>
                        <td algin='center' style="width:100px;">设备型号</td>
                        <td algin='center' style="width:80px;">设备信息</td>
                        <td algin='center' style="width:80px;">厂房区域</td>
                        <td algin='center' style="width:80px;">资产位置</td>
                        <td algin='center' style="width:70px;">故障描述</td>
                        <td algin='center' style="width:160px;">首选维修人员</td>
                        <td algin='center' style="width:70px;">实修人员</td>
                        <td algin='center' style="width:160px;">问题遗留原因</td>
                        <td algin='center' style="width:70px;">维修状态</td>
                    </tr>
                </thead>

            </table>
            <table class="table" style='width:1460px;' id="table">
                <tbody id="tbodyHtml" style="display: block;height: 450px;overflow-y: scroll;overflow-x: auto;">
                </tbody>
            </table>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">
    //光标所在id
    // var idSelector = "";
    var statusFlag = "";

    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }
    //初始化查询仓库下拉框
    apiready = function () {
        getEquipFaultList()
    }

    //跳转详情页面
    function goPageDetail() {
        //打开页面
        api.openWin({
            name: 'jxPersonScreen',
            url: 'jxPersonScreen' + '.html',
        });
    }



    function getEquipFaultList(status) {
        if (status == '0') {
            if (statusFlag == '0') {
                statusFlag = ''
            } else {
                statusFlag = '0'
            }
        }
        if (status == '2') {
            if (statusFlag == '2') {
                statusFlag = ''
            } else {
                statusFlag = '2'
            }
        }
        if (status == 'wtyl') {
            if (statusFlag == 'wtyl') {
                statusFlag = ''
            } else {
                statusFlag = 'wtyl'
            }
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getEquipFaultList";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                appVersion: api.appVersion,
                status: statusFlag,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 30,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //返回成功
                if (myobj.code == "0") {

                    var list = eval(myobj.list);

                    var html = "";

                    //发货单明细数据存在
                    if (list.length > 0) {

                        //遍历
                        for (var i = 0; i < list.length; i++) {
                            html += "<tr style='text-align: center;color: black;font-size: 12px;background-color: #F5F5F5;white-space: pre-wrap'>";
                            html += "<td name='seqNo' style='width:50px;'>" + (i + 1) + "</td>";
                            html += "<td name='createId'  style='width:140px;'>" + (list[i].createId == null ? "" : list[i].createId) + "</td>";
                            html += "<td name='contact' style='width:140px;'>" + (list[i].contact == null ? "" : list[i].contact) + "</td>";
                            html += "<td name='createDate' style='width:140px;'>" + (list[i].createDate == null ? "" : list[i].createDate) + "</td>";
                            // 根据ext13的值设置背景颜色
                            var ext13Style = "width:120px;";
                            if (list[i].ext13 === "机修") {
                                ext13Style += "background-color: lightgreen;";
                            } else if (list[i].ext13 === "电修") {
                                ext13Style += "background-color: lightblue;";
                            }
                            html += "<td name='ext13' style='" + ext13Style + "'>" + (list[i].ext13 == null ? "" : list[i].ext13) + "</td>";
                            html += "<td name='equipModel' style='width:100px;'>" + (list[i].equipModel == null ? "" : list[i].equipModel) + "</td>";
                            html += "<td name='equipCode' style='width:80px;'>" + (list[i].equipCode == null ? "" : list[i].equipCode) + "<br/>" + (list[i].equipName == null ? "" : list[i].equipName) + "</td>";
                            html += "<td name='locationName' style='width:80px;'>" + (list[i].locationName == null ? "" : list[i].locationName) + "<br/>" + (list[i].areaName == null ? "" : list[i].areaName) + "</td>";
                            html += "<td name='qty' style='width:80px;'>" + (list[i].geographiclocation == null ? "" : list[i].geographiclocation) + "</td>";
                            html += "<td name='lastLotCode' style='width:70px;'>" + (list[i].description == null ? "" : list[i].description) + "</td>";
                            html += "<td name='ext26' style='width:160px;'>" + (list[i].ext26 == null ? "" : list[i].ext26) + "</td>";
                            html += "<td name='ext19' style='width:70px;'>" + (list[i].ext19 == null ? "" : list[i].ext19) + "</td>";
                            html += "<td name='ext07' style='width:160px;'>" + (list[i].ext07 == null ? "" : list[i].ext07) + "</td>";


                            html += "<td name='status' style='width:70px;'>" + (list[i].status == null ? "" : list[i].status) + "</td>";
                            html += "</tr>";
                        }


                    }

                    $api.html($api.byId("tbodyHtml"), html);

                } else if (myobj.code == "1") {
                    //清空表格数据
                    $api.html($api.byId("tbodyHtml"), "");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //页面刷新
    function refresh() {
        getEquipFaultList();
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>